# @author: jungle
# @create : 2024/9/28 20:53
import sys

from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QLineEdit, QPushButton, QDesktopWidget

if __name__ == '__main__':
    app = QApplication(sys.argv)
    w = QWidget()
    # 设置窗口标题
    w.setWindowTitle("第一个PyQt程序")
    # w.setGeometry(100, 100, 500, 300)
    # 调整窗口大小
    w.resize(800, 600)

    # 将窗口设置在屏幕的左上角
    w.move(0, 0)

    # 调整窗口在屏幕中央显示
    center = QDesktopWidget().availableGeometry().center()
    x = center.x()
    y = center.y()
    # 元组可以直接解构 a, b = (1, 2)
    old_x, old_y, width, height = w.frameGeometry().getRect()
    new_x = int(x - (width / 2))
    new_y = int(y - (height / 2))
    w.move(new_x, new_y)
    # 展示窗口标题
    w.show()
    # 程序进行循环等待状态
    app.exec_()
